<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
<title>业务操作</title>
<%@ include file="/WEB-INF/jsp/public/commons.jspf"%>

<script type="text/javascript">
	function getGoodsId(dealType) {
		var isvarify = true;//通过校验
		var supplierId = $('#supplierList option:selected').val();//选中供应商
		var marketId = $('#marketList option:selected').val();//选中超市
		var goodsIdArray = new Array();
		$("input:checked").each(function() {
			goodsIdArray.push($(this).next().next().next().val());
		});

		if (isvarify == true) {
			$.ajax({
				type : "POST",
				url : "storage_ajaxGetOrderPara.do",
				data : "&goodsIdStr=" + goodsIdArray + "&supplierId="
						+ supplierId + "&marketId=" + marketId + "&dealType="
						+ dealType,
				success : function(msg) {
					location.href = "storage_toOrder.do?&dealType=" + dealType;
				}
			});
		}

	}
</script>
</head>
<body>
	<s:form action="storage_caozuo">
		<input type="hidden" name="GoodsName" value="${GoodsName}" />
		<input type="hidden" name="goodsCateId" value="${goodsCateId}" />
		<input type="hidden" name="dealType" value="${dealType}" />
		<input type="hidden" name="marketId" value="${marketId}" />
	</s:form>
	<div id="Title_bar">
		<div id="Title_bar_Head">
			<div id="Title_Head"></div>
			<div id="Title">
				<!--页面标题-->
				<img border="0" width="13" height="13"
					src="${pageContext.request.contextPath}/style/images/title_arrow.gif" />
				<s:if test="dealType == 1">上架选择</s:if>
				<s:if test="dealType == 2">下架选择</s:if>
				<s:if test="dealType == 3">进货选择</s:if>
				<s:if test="dealType == 4">退货选择</s:if>
			</div>
			<div id="Title_End"></div>
		</div>
	</div>

	<div id="QueryArea">
		<div style="height: 50px">
		<s:form action="storage_caozuo">
			<table>
				<tr>
					<td>订单对象：</td>
					<s:if test="dealType==1">
						<td>超市列表：</td>
						<td><s:select name="marketId" id="marketList"
								list="#marketList" listKey="id" listValue="name">
							</s:select></td>
					</s:if>
					<s:elseif test="dealType==2">
						<td>超市列表：</td>
						<td><s:select name="marketId" id="marketList"
								list="#marketList" listKey="id" listValue="name">
							</s:select></td>
					</s:elseif>
					<s:else>
						<td>供应商：</td>
						<td><s:select name="supplierId" id="supplierList"
								list="#supplierList" listKey="id" listValue="name">
							</s:select>
						</td>
					</s:else>
				</tr>
			</table>
				<input type="hidden" name="dealType" value="${dealType}" />
				<table>
					<tr>
						<td>商品分类：</td>
						<td><s:select name="goodsCateId" id="goodsCateList"
								list="#goodsCateList" listKey="id" listValue="name"
								headerKey="0" headerValue="所有分类" onchange="queryGoodList();">
							</s:select>
						</td>
						<td>商品名模糊查询：</td>
						<td><input type="text" id="GoodsName" name="GoodsName"
							value="${GoodsName}"> </input></td>
						<td><s:a>
								<input type="IMAGE"
									src="${pageContext.request.contextPath}/style/blue/images/button/query.PNG" />
							</s:a></td>
					</tr>
				</table>
			</s:form>
		</div>
	</div>

	<div id="MainArea">
		<table cellspacing="0" cellpadding="0" class="TableStyle">

			<!-- 表头-->
			<thead>
				<tr align=center valign=middle id=TableTitle>
					<s:if test="dealType == 2">
						<td width="100">请选择</td>
						<td width="100">商品名称</td>
						<td width="100">商品分类</td>
						<td width="200">商品单价</td>
						<td width="100">超架数量</td>
						<td width="100">所属超市</td>
					</s:if>
					<s:else>
						<td width="100">请选择</td>
						<td width="100">商品名称</td>
						<td width="100">商品分类</td>
						<td width="200">商品单价</td>
						<td width="100">库存数量</td>
					</s:else>
				</tr>
			</thead>

			<!--显示数据列表-->
			<tbody id="TableData" class="dataContainer" datakey="userList">
				<s:if test="dealType == 2">
					<s:iterator value="recordList" id="id">
						<tr align="center" valign="middle" class="TableDetail1 template">
							<td><s:checkbox id="ckx" name="name" value=""></s:checkbox> <s:hidden
									id="storageId" name="id"></s:hidden> <s:hidden id="goodsId"
									name="goods.id"></s:hidden></td>
							<td>${goods.name}</td>
							<td>${goods.goodsCate.name}</td>
							<td>${goods.price}</td>
							<td>${goodsNumber}</td>
							<td>${market.name}</td>
						</tr>
					</s:iterator>
				</s:if>
				<s:else>
					<s:iterator value="recordList" id="id">
						<tr align="center" valign="middle" class="TableDetail1 template">
							<td><s:checkbox id="ckx" name="name"></s:checkbox> <s:hidden
									id="storageId" name="id"></s:hidden> <s:hidden id="goodsId"
									name="goods.id"></s:hidden></td>
							<td>${goods.name}</td>
							<td>${goods.goodsCate.name}</td>
							<td>${goods.price}</td>
							<td>${goodsNumber}</td>
						</tr>
					</s:iterator>
				</s:else>
			</tbody>
		</table>

		<!-- 其他功能超链接 -->
		<div id="TableTail">
			<div id="TableTail_inside">
				<s:if test="dealType == 1">
					<button id="upStand" onclick="getGoodsId('1');">上架</button>
				</s:if>
				<s:if test="dealType == 2">
					<button id="upStand" onclick="getGoodsId('2');">下架</button>
				</s:if>
				<s:if test="dealType == 3">
					<button id="upGoods" onclick="getGoodsId('3');">进货</button>
				</s:if>
				<s:if test="dealType == 4">
					<button id="downGoods" onclick="getGoodsId('4');">退货</button>
				</s:if>
			</div>
		</div>
	</div>

	<!-- 分页信息 -->
	<%@ include file="/WEB-INF/jsp/public/pageView.jspf"%>

</body>
</html>
